<%@ page language="java" contentType="text/javascript; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import='java.sql.*' %>
<%@page import="java.util.ArrayList"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONSerializer"%>
<%@page import="net.sf.json.JSONArray"%>

<%String callback = request.getParameter("callback");%>
<%=callback %> (<%
		
	String userid = request.getParameter("userid");
	String userlat = request.getParameter("userlat");
	String userlng = request.getParameter("userlng");
	String usertheme = request.getParameter("usertheme");
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
		conn = DriverManager.getConnection(
			"jdbc:mysql://localhost/itscreater", "itscreater", "campus123");
		
		String update = "update UserInfo set UserLat = ?, UserLng = ?, UserTheme =?, UserTime= NOW() where ID = ?;";
		pstmt = conn.prepareStatement(update);
		pstmt.setString(1, userlat);
		pstmt.setString(2, userlng);
		pstmt.setString(3, usertheme);
		pstmt.setString(4, userid);
		pstmt.executeUpdate();
		
		JSONObject jo = new JSONObject();
		jo.put("success", "true");
		out.print(jo);	
	}
	
	finally{
		try{
			pstmt.close();
		}
		catch (Exception ignored){
		}
		try{
			conn.close();
		}
		catch (Exception ignored){
		}
	}
%>);